package com.admin.testproject.fragment

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.admin.testproject.R
import com.admin.testproject.Testbean
import kotlinx.android.synthetic.main.fragment_detail.view.*

/**
 * author 吴昶
 * date 2019/6/4
 * 标注
 */
class DetailFragment :Fragment(){

    private var fview:View?=null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        if(fview==null){
            fview= inflater.inflate(R.layout.fragment_detail,null)
        }
        val parent=fview?.parent
        if(parent!=null){
            (parent as ViewGroup).removeView(fview)
        }
        return fview
    }

    /**
     * 开放数据更新接口
      */
    fun setValueData(bean:Testbean){
        fview?.tv_detail_title!!.text=bean.title
        fview?.iv_image!!.setImageResource(bean.image)
    }

}